﻿<%@ Page Title="" Language="C#" MasterPageFile="~/ARS.Master" AutoEventWireup="true" CodeBehind="SearchFlight.aspx.cs" Inherits="NUS.ISS.ARS.Web.Booking.SearchFlight" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <div id="loginbox" class="mainbox">
	    <div class="panel panel-info well">
            <div>
                <asp:ValidationSummary ID="valildSummary" runat="server" class="errorSummary" HeaderText="Error Summary"/>
            </div>

		    <div class="panel-heading">
			    <div class="panel-title">Search Flight</div>
		    </div>

            <div class="panel-body">       
	            <form id="loginform" class="form-horizontal" role="form">
                    <div class="form-group">
				        <label class="col-md-4 control-label" for="ddlFromCities">From:</label>
                        <div>                            
                            <asp:DropDownList ID="ddlFromCities" runat="server" class="selectpicker"></asp:DropDownList> 
                            <asp:CustomValidator ID="cvddlFromCities" ControlToValidate="ddlFromCities" 
                                runat="server" Text="*" ErrorMessage="From City is required." OnServerValidate="ValidateFromCity"></asp:CustomValidator>
                        </div>                       
			        </div>

                    <div class="form-group">
				        <label class="col-md-4 control-label" for="ddlToCities">To: </label>
                        <div>                           
                            <asp:DropDownList ID="ddlToCities" runat="server" class="selectpicker">
                            </asp:DropDownList> 
                            <asp:CustomValidator ID="cvddlToCities" ControlToValidate="ddlToCities" 
                                runat="server" Text="*" ErrorMessage="To City is required." OnServerValidate="ValidateToCity"></asp:CustomValidator>
                        </div>                        
			        </div>  
                    
                     <div class="form-group">
				        <label class="col-md-4 control-label" for="rblBookingType"></label>
				        <div>					    
                            <asp:RadioButtonList ID="rblBookingType" runat="server" 
                                RepeatDirection="Horizontal" AutoPostBack="True" 
                                onselectedindexchanged="rblBookingType_SelectedIndexChanged" style="width: 200px">
                                <asp:ListItem Text="round trip" Value="roundtrip" Selected="True" />                                
                                <asp:ListItem Text="one way" Value="oneway" />
                            </asp:RadioButtonList>
                        </div>
			        </div>

                     <div class="form-group">
				        <label class="col-md-4 control-label" for="txtFromDate">Depart: </label>
				        <div class="col-md-5 error">
                            <asp:TextBox ID="txtFromDate" runat="server" placeholder="dd/mm/yyyy" data-date-format="dd/mm/yyyy" class="form-control input-md" readonly></asp:TextBox>   
                             <asp:CustomValidator ID="cvtxtFromDate" ControlToValidate="txtFromDate" 
                                runat="server" Text="*" ErrorMessage="Flight date cannot be today or earlier." OnServerValidate="ValidateFromDate"></asp:CustomValidator>               
				        </div>                        
			        </div>
                   
                    <div class="form-group" id="divReturnDate" runat="server">
				        <label class="col-md-4 control-label" for="txtToDate">Return: </label>
				        <div class="col-md-5 error">					       
                            <asp:TextBox ID="txtToDate" runat="server" placeholder="dd/mm/yyyy" data-date-format="dd/mm/yyyy" class="form-control input-md" readonly></asp:TextBox>
                            <asp:CustomValidator ID="cvtxtToDate" ControlToValidate="txtToDate" 
                             runat="server" Text="*" ErrorMessage="Return date cannot be earlier than depart date." OnServerValidate="ValidateToDate"></asp:CustomValidator>
				        </div>
			        </div>

                    <div class="form-group">
				    <label class="col-md-4 control-label" for="ddlAdult">Adult: </label>
				    <div class="col-md-6">					
                        <asp:DropDownList ID="ddlAdult" name="ddlAdult" runat="server" class="selectpicker" data-width="80px">
                            <asp:ListItem Value="1">1</asp:ListItem>
                            <asp:ListItem Value="2">2</asp:ListItem>
                            <asp:ListItem Value="3">3</asp:ListItem>
                            <asp:ListItem Value="4">4</asp:ListItem>
                            <asp:ListItem Value="5">5</asp:ListItem>
                            <asp:ListItem Value="6">6</asp:ListItem>
                            <asp:ListItem Value="7">7</asp:ListItem>
                            <asp:ListItem Value="8">8</asp:ListItem>
                            <asp:ListItem Value="9">9</asp:ListItem>
                            <asp:ListItem Value="10">10</asp:ListItem>
                        </asp:DropDownList> 
				    </div>
			    </div>

                 <div class="form-group">
				    <label class="col-md-4 control-label" for="ddlChild">Child: </label>
				    <div class="col-md-6">					
                        <asp:DropDownList ID="ddlChild" name="ddlChild" runat="server" class="selectpicker" data-width="80px">    
                                    <asp:ListItem Value="0">0</asp:ListItem>
                                    <asp:ListItem Value="1">1</asp:ListItem>
                                    <asp:ListItem Value="2">2</asp:ListItem>
                                    <asp:ListItem Value="3">3</asp:ListItem>
                                    <asp:ListItem Value="4">4</asp:ListItem>
                                    <asp:ListItem Value="5">5</asp:ListItem>
                                    <asp:ListItem Value="6">6</asp:ListItem>
                                    <asp:ListItem Value="7">7</asp:ListItem>
                                    <asp:ListItem Value="8">8</asp:ListItem>
                        </asp:DropDownList>
                    </div>
			    </div>

                <div class="form-group">
				    <label class="col-md-7 control-label" for="search"></label>
				    <div class="col-md-3">					
                        <asp:Button ID="btnSubmit" runat="server" onclick="btnSubmit_Click" Text="Submit" class="btn btn-primary"/>
				    </div>
			    </div>

             </form>

        </div>
	</div>
</div>

<script>

    $(document).ready(function () {
        $('.selectpicker').selectpicker();

        var nowTemp = new Date();
        var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(),
				nowTemp.getDate(), 0, 0, 0, 0);

        var checkin = $("input[id$='txtFromDate']").datepicker({
            onRender: function (date) {
                return date.valueOf() <= now.valueOf() ? 'disabled' : '';
            }
        }).on('changeDate', function (ev) {
            if (checkout && checkout.date) {
                if (ev.date.valueOf() > checkout.date.valueOf()) {
                    var newDate = new Date(ev.date)
                    newDate.setDate(newDate.getDate() + 1);
                    checkout.setValue(newDate);
                }
            }
            checkin.hide();
            if ($("input[id$='txtToDate']") && $("input[id$='txtToDate']")[0]) {
                $("input[id$='txtToDate']")[0].focus();
            }
        }).data('datepicker');
        var checkout = $("input[id$='txtToDate']")
				.datepicker(
						{
						    onRender: function (date) {
						        return date.valueOf() <= checkin.date
										.valueOf() ? 'disabled' : '';
						    }
						}).on('changeDate', function (ev) {
						    checkout.hide();
						}).data('datepicker');

    });

</script>

</asp:Content>
